<%@page contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>首页</title>
<%@ include file="common.jsp"%>
<script type="text/javascript">
				
	$(function(){
			$('#pp').portal({
				border:false,
				fit:true
			});
					//add();
		});
	function add(){
					for(var i=0; i<3; i++){
						var p = $('<div/>').appendTo('body');
						p.panel({
							title:'Title'+i,
							content:'<div style="padding:5px;">Content'+(i+1)+'</div>',
							height:100,
							closable:true,
							collapsible:true
						});
						$('#pp').portal('add', {
							panel:p,
							columnIndex:i
						});
					}
					$('#pp').portal('resize');
				}
		function remove(){
					$('#pp').portal('remove',$('#pgrid'));
					$('#pp').portal('resize');
		}
		
		
		$(function(){
			$('#main-info').treegrid({
				iconCls:'icon-save',
				width:661,
				height:300,
				nowrap: false,
				rownumbers: true,
				animate:true,
				collapsible:true,
				pageSize:5,
				url:'<%=basePath%>contractInfoAction!loadMainContractInfo.do',
				idField:'name',
				treeField:'name',
				pagination:"true",
				frozenColumns:[[
	                {title:'合同名称',field:'name',width:200,
		                formatter:function(value){
		                	return '<span style="color:red">'+value+'</span>';
		                }
	                }
				]],
				columns:[[
					{field:'createTime',title:'创建时间',width:140},
					{field:'budgetPrice',title:'预算价格',width:80},
					{field:'contractPrice',title:'合同价格',width:80},
					{field:'contract_remark',title:'合同说明',width:180}
				]],
				
				onContextMenu: function(e,row){
					e.preventDefault();
					$(this).treegrid('unselectAll');
					$(this).treegrid('collapseAll');
					$(this).treegrid('select', row.code);
					$('#mm').menu('show', {
						left: e.pageX,
						top: e.pageY
					});
				}
			});
		});
		
		
		$(function(){
			var p = $('#main-info').datagrid('getPager');       
			 $(p).pagination({  
				 pageSize: 5,//每页显示的记录条数，默认为10           
				 pageList: [5,10,15]//可以设置每页记录条数的列表
			 });
		});
		function reload(){
			var node = $('#main-info').treegrid('getSelected');
			if (node){
				$('#main-info').treegrid('reload', node.code);
			} else {
				$('#main-info').treegrid('reload');
			}
		}
	
		function collapseAll(){
			var node = $('#main-info').treegrid('getSelected');
			if (node){
				$('#main-info').treegrid('collapseAll', node.code);
			} else {
				$('#main-info').treegrid('collapseAll');
			}
		}
		
			
		function expandAll(){
			var node = $('#main-info').treegrid('getSelected');
			if (node){
				$('#main-info').treegrid('expandAll', node.code);
			} else {
				$('#main-info').treegrid('expandAll');
			}
		}
		
		
		// 查询
		function search_data(){	
			var ct_name =$("#ct_name").attr('value');
			var d_start = $("#dd1").datebox("getText");
			var d_end= $("#dd2").datebox("getText");
			
			var url = "<%=basePath%>contractInfoAction!loadMainContractInfo.do?contractInfo.contractName="+ct_name+"&contractInfo.query_startTime="+d_start+"&contractInfo.query_endTime="+d_end;
			var params = {} ;
			jQuery.post(url,params,function(data){
				//alert(data);
				$('#main-info').treegrid("loadData",data);
			
			},'json');
		}
		
		
		$(document).ready(function(){
			
			$(function(){
				$('#dd1').datebox({
				    formatter: function(date){ return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();},
				    parser: function(date){ return new Date(Date.parse(date.replace(/-/g,"/")));}
				});
				$('#dd2').datebox({
				    formatter: function(date){ return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();},
				    parser: function(date){ return new Date(Date.parse(date.replace(/-/g,"/")));}
				});
			})
			
			//
			$('#main-info').treegrid('collapseAll');
			
		})
		
		
		
		
	</script>
</head>
<<body class="easyui-layout">
<div region="center" border="false">
   <div id="pp" style="position:relative">
	<div style="width:20%;">
		<div title="公告" style="text-align:center;background:#f3eeaf;height:150px;padding:5px;">
					
	    </div>
	    <div title="链接" collapsible="true" closable="true" style="height:200px;padding:5px;">
	    
	    </div>
	</div>
	<div style="width:60%;">
		<div id="pgrid" title="主信息" closable="true" style="height:370px;">
				<table border="0" width="100%" height="20px" style="text-align:center;background:#f3eeaf;">
					<tr>
						<td width="60">日期 开始:</td>
						<td><input class="easyui-datebox" style="width:100px" id="dd1">至: <input class="easyui-datebox" style="width:100px" id="dd2"></td>
						<td width="60">合同名称: </td>
						<td><input  style="width:150px" id="ct_name" name="ct_name"></td>
						<td><a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-search" onclick="search_data()">查询</a></td>
					</tr>		
				 </<table>
			
				<div id="toolbar">
						<a href="#" onclick="reload()" class="easyui-linkbutton" plain="true" iconCls="icon-reload">刷新</a>
						<a href="#" onclick="collapseAll()" class="easyui-linkbutton" plain="true" iconCls="icon-cancel" >收起</a>
						<a href="#" onclick="expandAll()" class="easyui-linkbutton" plain="true" iconCls="icon-ok" >展开</a>	
				</div>
					
			<table id="main-info" toolbar="#toolbar"></table>
		</div>
	</div>

	<div style="width:20%;">
		<div title="查询" iconCls="icon-search" closable="true" style="height:80px;padding:10px;">
			<input class="easyui-searchbox">
		</div>
		<div title="待办" closable="true" style="height:200px;text-align:center;">
						
		</div>
	</div>


</div>
</div>

</body>
</html>